#pragma once
#ifndef __SCENE_MANAGER_H__
#define __SCENE_MANAGER_H__

#include "pch.h"
#include "prerequisites.h"
#include "singleton.h"
#include "scene_node.h"

class c_scene : public c_singleton<c_scene>
{
public:
    c_scene(); 
    virtual ~c_scene(); 
    
    camera_ptr create_camera(const std::string& name, const c_vector3& position, const c_vector3& lookat, const c_vector3& up, const frustum_ptr& frustum); 
    mesh_entity_ptr create_entity(const std::string& name, mesh_ptr& mesh_ptr); 
    
    void add_scene_node(const scene_node_ptr& node_ptr);
    void add_camera(const camera_ptr& camera);
    
    const camera_ptr& get_active_camera() const { return m_active_camera; }
    
    void update_scene(float dt); 
    /** 
        render scene : 
            frustum culling -> visible scene nodes -> sorting & grouping -> render queue -> render
    */  
    void render_scene(); 
   
private:
    void create_root(); 
    
private:
    scene_node_ptr m_root_node;
    
    /** special nodes: 
        camera

    */
    typedef std::vector<camera_ptr> camera_vec_t;
    camera_vec_t m_camera_nodes;
    camera_ptr m_active_camera; 
};

#endif